<?php
/**
 * Created by PhpStorm.
 * User: 1
 * Date: 2016-10-02
 * Time: 16:08
 */

namespace app\index\controller;


use app\src\account\enmu\AccountEnmu;
use app\src\accountScore\logic\AccountScoreLogic;
use app\src\accountScore\model\AccountScore;
use app\src\alibaichuan\service\OpenIMUserService;
use app\src\base\helper\PageHelper;
use app\src\deleteApply\enum\DeleteApplyType;
use app\src\deleteApply\logic\DeleteApplyLogic;
use app\src\filiation\action\FiliationAction;
use app\src\filiation\logic\FiliationLogic;
use app\src\invite\action\InviteCodeAction;
use app\src\invite\logic\InviteCodeLogic;
use app\src\platform\logic\PlatformLogic;
use app\src\profit\action\ProfitAction;
use app\src\rfpay\po\RfNoCardBalanceReq;
use app\src\rfpay\po\RfNoCardOrderCreateReq;
use app\src\rfpay\service\RfNoCardOrderService;
use app\src\rfpay\utils\RsaUtils;
use app\src\seller\helper\AddressHelper;
use app\src\seller\logic\SellerLogic;
use app\src\seller\logic\SellerPromotionLogic;
use app\src\tool_email\helper\EmailHelper;
use app\src\user\enum\RoleEnum;
use app\src\user\logic\MemberConfigLogic;
use app\src\userRoles\logic\UserRolesLogic;
use think\Controller;
use wordFilter\WordFilter;

class Test extends Controller
{
    public function testAddPlatform()
    {
        return;
        $entity = [
            'group_id' => 1,
            'name' => 'BOYE个人创业',
            'city_code' => '330100',
            'province_code' => '330000',
            'create_time' => 1497421068,
            'status' => 0
        ];
        $result = (new PlatformLogic)->addPlatform(3, $entity);
        dump($result);
    }

    public function testAddRole()
    {
        $result = (new UserRolesLogic)->addRole(2, RoleEnum::ROLE_Seller);
        dump($result);
    }

    public function testGetRoles()
    {
        $result = (new UserRolesLogic)->getRoles(2);
        dump($result);
    }

    public function testAddSeller()
    {
        return;
        $entity = [
            'uid' => 2,
            'waiter_id' => 3,
            'name' => '这不科学的店铺',
            'grade' => 5,
            'position' => '浙江省杭州市江干区学府街515号杭州智慧谷移动互联网大厦8楼803',
            'lng' => '120.377957',
            'lat' => '30.316792',
            'parent_id' => 4
        ];
        
        $result = (new SellerLogic)->addSeller($entity);
        dump($result);
    }

    public function testAddFiliation()
    {
        $result = (new FiliationAction)->addByInviteCode(2, '01144V');
        dump($result);
    }

    public function testQueryNearbySeller()
    {
        $result = (new SellerLogic)->getNearby('120.333082', '30.32094', 5000, false, new PageHelper(['page_index' => 1, 'page_size' => 10]));
        dump($result);
    }

    public function testAddScore()
    {
//        $result = (new AccountScoreLogic)->plusScore(AccountEnmu::USER, 2, );
        dump($result);
    }

    public function addScore()
    {
        $result = (new AccountScoreLogic)->plusScore(0, 2, AccountScoreLogic::SCORE_TYPE_1, 100, '测试');
        dump($result);
    }

    public function getAddressPos()
    {
        $ret = (AddressHelper::getAddressPos('xx'));
        if($ret['status'] == 0){
            dump($ret['result']['location']);

        }else{
            dump($ret);
        }

    }

    public function sellerOrderSum()
    {
        $map = [
            'order_status' => ['=', 1]
        ];
        $result = (new SellerLogic)->querySellerOrderSum($map);
        dump($result);
    }

    public function testReg()
    {
        $uid = 40;
        //4. 根据邀请码添加关系
        $invite_code = '02144V';
        $result = (new InviteCodeAction)->check($invite_code);
        if(!$result['status']) $this->error('错误的邀请码');
        (new FiliationAction)->addByInviteCode($uid, $invite_code);

        //5. 生成邀请码
        (new InviteCodeAction())->create(AccountEnmu::USER, $uid);

        dump('ok');
    }

    public function testFilter()
    {
        $ret = (new WordFilter)->filter('操B好爽，好舒服，你妈龟头，还好');
        dump($ret);
    }

    public function testDeleteApply()
    {
        $result = (new DeleteApplyLogic)->addApply(DeleteApplyType::SELLER, 5, 4);
        dump($result);

    }

    public function updateSellerPromotion()
    {
        dump((new SellerPromotionLogic)->updatePromotion(1,1, ['title' => '满100减50', 'detail' => '跳楼大甩卖，吐血不回本', 'img' => 52]));
    }

    public function testFiliation()
    {
        //$result = (new FiliationLogic)->addByInviteCode(180, '02144U');
        dump($result);
    }


    /*
     * test
     */
    public function test(){
        $order_id = 152;
        $ts = (new ProfitAction())->orderps($order_id,false);
        dump($ts);
    }

}